import { _mallStore } from "@/store/config";
import { TypeFilters } from "@/interface/filters";

import {
    getIncludeFilters,// 获取部分状态
    getExcludeFilters,// 排除部分状态

    getFiltersDictLabel, // 字典 value:label
    getFiltersDictColor, // 字典 value:color
    getFiltersDictText, getFiltersDictParaphrase, // 字典 value:text
} from "@/filters/utils";

import {
    GenderFilters, // 性别
    PremiumStatus,// 付费会员 开通状态
    MemberStatus,// 会员管理 状态
    CouponTypes,// 优惠券 类型
    CouponStatus,// 优惠券 状态
    CouponChannel,// 优惠券 适用范围
    ReceiveRules,// 优惠券 是否限领
    CouponPriceType,// 优惠券 定价方式
    CouponScanCodeSubTypes,// 优惠券 扫码发券
    PayWayFilters,// 支付方式
    PayOriginFilters,
    SendPlatform,
} from "@/filters/data";

// 性别 ========================================================================
export const FGender: TypeFilters.filter[] = GenderFilters();
export const FGenderLabel: ObjValueStr = getFiltersDictLabel(FGender);

// 付费会员 开通状态 ========================================================================
export const FPremiumStatus: TypeFilters.filter[] = PremiumStatus();
export const FPremiumStatusLabel: ObjValueStr = getFiltersDictLabel(FPremiumStatus);

// 会员管理 ========================================================================
export const FMemberStatus: TypeFilters.filter[] = MemberStatus();
export const FMemberStatusColor: ObjValueStr = getFiltersDictColor(FMemberStatus);
export const FMemberStatusLabel: ObjValueStr = getFiltersDictLabel(FMemberStatus);

// 优惠券 ========================================================================
// 扫码发券 二级选项
export const FCouponScanCodeSubTypes: TypeFilters.filter[] = CouponScanCodeSubTypes();
export const FCouponScanCodeSubTypesLabel: ObjValueStr = getFiltersDictLabel(FCouponScanCodeSubTypes);
// 发放平台
export const FSendPlatform: TypeFilters.filter[] = SendPlatform();
export const FSendPlatformLabel: ObjValueStr = getFiltersDictLabel(FSendPlatform);
// 券状态
export const FCouponStatus: TypeFilters.filter[] = CouponStatus();
export const FCouponStatusLabel: ObjValueStr = getFiltersDictLabel(FCouponStatus);
export const FCouponStatusColor: ObjValueStr = getFiltersDictColor(FCouponStatus);
export const FCouponStatusParaphrase: ObjValueNum = getFiltersDictParaphrase(FCouponStatus);
// 定价方式
export const FCouponPriceType: TypeFilters.filter[] = CouponPriceType();
export const FCouponPriceTypeLabel: ObjValueStr = getFiltersDictLabel(FCouponPriceType);
// 适用范围
export const FCouponChannel: TypeFilters.filter[] = CouponChannel();
export const FCouponChannelLabel: ObjValueStr = getFiltersDictLabel(FCouponChannel);
export const FCouponChannelText: ObjValueStr = getFiltersDictText(FCouponChannel);
export const FCouponChannelParaphrase: ObjValueNum = getFiltersDictParaphrase(FCouponChannel);
// 是否限领
export const FReceiveRules: TypeFilters.filter[] = ReceiveRules();
export const FReceiveRulesLabel: ObjValueStr = getFiltersDictLabel(FReceiveRules);
// 券类型
const storeCouponTypes: TypeFilters.filter[] = CouponTypes();
export const FCouponTypesLabel: ObjValueStr = getFiltersDictLabel(storeCouponTypes);
export const FCouponTypesParaphrase: ObjValueNum = getFiltersDictParaphrase(storeCouponTypes);
// 券类型 信息
export const CouponTypeHandlerText = (row: ObjValueAny = {}): ObjValueAny => {
    const _type: string = String(row.soule);
    const _value: ObjValueAny = {};
    switch (_type) {
        case '1': //满减券
            _value.price = row.minus + '元';
            _value.type = `满${row.over}可用`;
            _value.text = `满${row.over}元减${_value.minus}`;
            break;
        case '2': //折扣券
            _value.price = row.off + '折';
            _value.type = `${row.purchase}件即享`;
            _value.text = `${row.purchase}件${_value.off}`;
            break;
        case '3': //礼品券
            _value.price = '礼品券';
            _value.type = row.demand || '到店领取';
            _value.text = row.demand;
            break;
        case '4': //现金券
            _value.price = row.minus + '元';
            _value.type = row.demand || '无门槛使用';
            _value.text = `${row.minus}元现金券`;
            break;
        case '5': //抵扣券
            _value.price = row.arrive + '元';
            _value.type = `可抵${row.over}元`;
            _value.text = `${row.arrive}元抵${row.over}元`;
            break;
        case '7': //停车券
            _value.price = row.free_park_hour + '小时免费停车';
            _value.type = '';
            _value.text = `${row.free_park_hour}小时免费停车`
            break;
    }
    return _value;
};
// 免费优惠券 类型
export const FCouponTypes: TypeFilters.filter[] = getExcludeFilters(storeCouponTypes, [5, 7]);// 不包含 5:抵用券、7:时长券
// 停车券 类型
const parkCouponTypesIncludeValues = [2, 4];// 4现金券、2折扣券
if (_mallStore.isSupportTimeDeduction) {
    parkCouponTypesIncludeValues.push(7);// 7时长券
}
export const FParkCouponTypes: TypeFilters.filter[] = getIncludeFilters(storeCouponTypes, parkCouponTypesIncludeValues);

// 消费记录来源 ========================================================================
export const FPayOriginFilters: TypeFilters.filter[] = PayOriginFilters();

// 支付方式 ========================================================================
export const FPayWayFilters: TypeFilters.filter[] = PayWayFilters();